<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:zj="http://www.zju.edu.cn" exclude-result-prefixes="zj">
  <xsl:import href="../Tk2Base/Button.xslt"/>
  <xsl:import href="../Tk2Base/DetailItems.xslt"/>
  <xsl:param name="Doc"/>
  <!--xsl:variable name="Doc" select="document('Temp.xml')"/-->
  <xsl:variable name="zj:Toolkit" select="/Toolkit"/>
  <xsl:variable name="zj:XmlData" select="$Doc"/>
  <xsl:template name="zj:Content">
    <xsl:apply-templates select="$zj:XmlData/Toolkit/zj:Table[@Style='Normal']" mode="zj:Display"/>
  </xsl:template>
  <xsl:template match="zj:Table" mode="zj:Display">
    <xsl:variable name="Data" select="$zj:Toolkit/*[local-name()=current()/@TableName]"/>
    <xsl:call-template name="zj:NormalDisplay">
      <xsl:with-param name="Data" select="$Data"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="zj:NormalDisplay">
    <xsl:param name="Data"/>
    <xsl:variable name="current" select="."/>
    <xsl:if test="@TableDesc != ''">
      <tr>
        <th width="100%">
          <div align="left">
            <xsl:value-of select="@TableDesc"/>
          </div>
        </th>
        <th align="right" class="cur-hand" onclick="showContentList('{@TableName}');">
          <img src="../images/ico_listup.gif" id="imgContentList{@TableName}" border="0" align="right"/>
        </th>
      </tr>
    </xsl:if>
    <tr>
      <td colspan="2" class="td-bg" id="divContentList{@TableName}">
        <xsl:if test="@Expand='false'">
          <xsl:attribute name="style">display: none</xsl:attribute>
        </xsl:if>
        <xsl:for-each select="$Data">
          <table width="100%" border="0" cellspacing="1" cellpadding="1">
            <xsl:apply-templates select="$current/Hidden/zj:Field" mode="zj:Item">
              <xsl:with-param name="DataRecord" select="."/>
            </xsl:apply-templates>
            <xsl:apply-templates select="$current/Row" mode="zj:TableRow">
              <xsl:with-param name="DataRecord" select="."/>
            </xsl:apply-templates>
          </table>
        </xsl:for-each>
      </td>
    </tr>
  </xsl:template>
  <xsl:template match="Row" mode="zj:TableRow">
    <xsl:param name="DataRecord"/>
    <tr>
      <xsl:apply-templates select="zj:Field" mode="zj:Item">
        <xsl:with-param name="DataRecord" select="$DataRecord"/>
      </xsl:apply-templates>
    </tr>
  </xsl:template>
  <xsl:template match="zj:Field" mode="zj:Item">
    <xsl:param name="DataRecord"/>
    <xsl:variable name="HtmlCtrl" select="zj:HtmlCtrl/@HtmlCtrl"/>
    <xsl:variable name="Value" select="$DataRecord/*[local-name()=current()/zj:FieldName]"/>
    <xsl:choose>
      <xsl:when test="$HtmlCtrl='Hidden'">
        <xsl:call-template name="zj:Hidden">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='Detail'">
        <xsl:call-template name="zj:Detail">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='DetailHidden'">
        <xsl:call-template name="zj:DetailHidden">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='DetailMultiSelect'">
        <xsl:call-template name="zj:DetailMultiSelect">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='DetailUpload'">
        <xsl:call-template name="zj:DetailUpload">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="DataRecord" select="$DataRecord"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='DetailHTML'">
        <xsl:call-template name="zj:DetailHTML">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='DetailTextArea'">
        <xsl:call-template name="zj:DetailTextArea">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="Value" select="$Value"/>
        </xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
